package State;

import Factory.AgriculturalMachine;
import java.util.Date;

public class WorkingState implements MachineState {
    private AgriculturalMachine machine;
    private Date startTime;

    public WorkingState(AgriculturalMachine machine) {
        this.machine = machine;
        this.startTime = new Date();
    }

    @Override
    public void start() {
        System.out.println("机器已经在工作中");
    }

    @Override
    public void stop() {
        System.out.println("机器停止工作");
        machine.setState(new IdleState(machine));
    }

    @Override
    public void pause() {
        System.out.println("机器暂停工作");
        machine.setState(new PausedState(machine));
    }

    @Override
    public void resume() {
        System.out.println("机器已经在工作中，无需恢复");
    }

    @Override
    public void execute() {

    }

    @Override
    public String getStateName() {
        return "工作中";
    }

    @Override
    public String getStateDescription() {
        return "机器正在正常工作，执行工作任务";
    }

    @Override
    public Date getStateStartTime() {
        return startTime;
    }

    @Override
    public long getStateDuration() {
        return new Date().getTime() - startTime.getTime();
    }

    @Override
    public String toString() {
        return "工作";
    }
}
